|
1
|
|
|
/** global: GLSR, jQuery */ |
|
2
|
|
|
|
|
3
|
|
|
GLSR.keys = { |
|
4
|
|
|
DOWN: 40, |
|
5
|
|
|
ENTER: 13, |
|
6
|
|
|
ESC: 27, |
|
7
|
|
|
SPACE: 32, |
|
8
|
|
|
UP: 38, |
|
9
|
|
|
}; |
|
10
|
|
|
|
|
11
|
|
|
jQuery( function() { |
|
12
|
|
|
GLSR.ColorPicker(); |
|
13
|
|
|
new GLSR.Forms( 'form.glsr-form' ); |
|
14
|
|
|
new GLSR.Logger(); |
|
15
|
|
|
new GLSR.Pinned(); |
|
16
|
|
|
new GLSR.Pointers(); |
|
17
|
|
|
new GLSR.Search( '#glsr-search-posts', { |
|
18
|
|
|
action: 'search-posts', |
|
19
|
|
|
onInit: function() { |
|
20
|
|
|
this.el.on( 'click', '.glsr-remove-button', this.onUnassign_.bind( this )); |
|
21
|
|
|
}, |
|
22
|
|
|
onResultClick: function( ev ) { |
|
23
|
|
|
var result = x( ev.target ); |
|
24
|
|
|
var template = wp.template( 'glsr-assigned-post' ); |
|
|
|
|
|
|
25
|
|
|
var entry = { |
|
26
|
|
|
url: result.data( 'url' ), |
|
27
|
|
|
title: result.text(), |
|
28
|
|
|
}; |
|
29
|
|
|
if( template ) { |
|
30
|
|
|
this.el.find( 'input#assigned_to' ).val( result.data( 'id' )); |
|
31
|
|
|
this.el.find( '.description' ).html( template( entry )); |
|
32
|
|
|
this.el.on( 'click', '.glsr-remove-button', this.onUnassign_.bind( this )); |
|
33
|
|
|
this.reset_(); |
|
34
|
|
|
} |
|
35
|
|
|
}, |
|
36
|
|
|
}); |
|
37
|
|
|
new GLSR.Search( '#glsr-search-translations', { |
|
38
|
|
|
action: 'search-translations', |
|
39
|
|
|
onInit: function() { |
|
40
|
|
|
this.makeSortable_(); |
|
41
|
|
|
}, |
|
42
|
|
|
onResultClick: function( ev ) { |
|
43
|
|
|
var result = x( ev.target ); |
|
44
|
|
|
var entry = result.data( 'entry' ); |
|
45
|
|
|
var template = wp.template( 'glsr-string-' + ( entry.p1 ? 'plural' : 'single' )); |
|
|
|
|
|
|
46
|
|
|
entry.index = this.options.entriesEl.children().length; |
|
47
|
|
|
entry.prefix = this.options.resultsEl.data( 'prefix' ); |
|
48
|
|
|
if( template ) { |
|
49
|
|
|
this.options.entriesEl.append( template( entry )); |
|
50
|
|
|
this.options.exclude.push({ id: entry.id }); |
|
51
|
|
|
this.options.results = this.options.results.filter( function( i, el ) { |
|
52
|
|
|
return el !== result.get(0); |
|
53
|
|
|
}); |
|
54
|
|
|
} |
|
55
|
|
|
this.setVisibility_(); |
|
56
|
|
|
}, |
|
57
|
|
|
}); |
|
58
|
|
|
new GLSR.Status( 'a.glsr-change-status' ); |
|
59
|
|
|
new GLSR.Tabs(); |
|
60
|
|
|
new GLSR.TextareaResize(); |
|
61
|
|
|
}); |
|
62
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.